package com.itasura.mybatisannotation.mapper;


import com.itasura.mybatisannotation.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from user")
    @Results({
            @Result(property = "name", column = "name"),
            @Result(property = "sex", column = "sex")
    })
    List<User> getAll();

    @Select("select * from user where id = #{id}")
    @Results({
            @Result(property = "name", column = "name"),
            @Result(property = "sex", column = "sex")
    })
    User getByPrimaryId(Long id);

    @Insert("insert into user(name,sex) values(#{name}, #{sex})")
    void insert(User user);

    @Update("update user set name=#{name},sex=#{sex} where id =#{id}")
    void update(User user);

    @Delete("delete from user where id =#{id}")
    void delete(Long id);

}